package com.yanggeng.demo.beginnerguidedemo.activity

import android.annotation.SuppressLint
import android.os.Bundle
import android.support.design.internal.BottomNavigationItemView
import android.support.design.internal.BottomNavigationMenuView
import android.util.Log
import com.yanggeng.demo.beginnerguidedemo.R
import kotlinx.android.synthetic.main.activity_bottom_navigation.*

class BottomNavigationActivity: BaseActivity() {

    @SuppressLint("RestrictedApi")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_bottom_navigation)
        setTitle("BottomNavigationView")

        val menuView = bottom_navigation.getChildAt(0) as BottomNavigationMenuView

        val shiftMode = menuView.javaClass.getDeclaredField("mShiftingMode")
        shiftMode.isAccessible = true
        shiftMode.setBoolean(menuView, false)
        shiftMode.isAccessible = false

        for(i in 0 until menuView.childCount) {
            Log.e(TAG, i.toString())
            val itemView = menuView.getChildAt(i) as BottomNavigationItemView
            itemView.setShiftingMode(false)
            itemView.setChecked(itemView.itemData.isChecked)
        }
    }
}